
Ext.define('Noter.stores.Notes' , {
    extend    : 'Ext.data.Store',
    requires  : ['Noter.models.Note'] ,
    autoLoad  : true,
    autoSync  : true,
    remoteSort: true,
    pageSize  : 10,
    model     : 'Noter.models.Note' ,
    proxy: {
        type: 'rest',
        url: '/note',
        reader: {
            type: 'json',
            root: 'rows',
            totalProperty: 'total'
        },
        writer: {
            type: 'json'
        }
    },
    listeners: {
        write: function(store, operation){
            var record = operation.getRecords()[0],
                name = Ext.String.capitalize(operation.action),
                verb;
                
                
            if (name == 'Destroy') {
                record = operation.records[0];
                verb = 'Destroyed';
            } else {
                verb = name + 'd';
            }
            console.log(name, Ext.String.format("{0} user: {1}", verb, record.getId()));
        }
    }
});
